package com.huilian.iotbox.admin.wap.controller;

import com.huilian.iotbox.admin.wap.service.DeviceAnnualFeeService;
import com.huilian.iotbox.data.common.ServerResponse;
import com.huilian.iotbox.data.dto.DeviceAnnualFeeDto;
import com.huilian.iotbox.data.vo.UserInfo;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;

/**
 * @author: loong
 * @create: 2024-06-24 10:13
 **/

@RestController
@RequestMapping("/api/deviceAnnualFee")
public class DeviceAnnualFeeController extends UserInfoController {
    @Resource
    private DeviceAnnualFeeService deviceAnnualFeeService;

    /**
     * 根据用户查找设备
     *
     * @param request
     * @return
     */
    @GetMapping("/findByUserId")
    public ServerResponse findByUserId(HttpServletRequest request) {
        UserInfo userInfo = super.getLoginUserInfo(request);
        return ServerResponse.createBySuccess(deviceAnnualFeeService.findByUserId(userInfo));
    }

    /**
     * 根据设备id 分组查找相应价格
     *
     * @param deviceAnnualFeeDto
     * @return
     */
    @PostMapping("/findStatisticsById")
    public ServerResponse findStatisticsById(@RequestBody DeviceAnnualFeeDto deviceAnnualFeeDto) {
        return ServerResponse.createBySuccess(deviceAnnualFeeService.findStatisticsById(deviceAnnualFeeDto));
    }

    /**
     * 根据用户查找设备
     *
     * @param request
     * @return
     */
    @GetMapping("/findExpireListByUserId")
    public ServerResponse findExpireListByUserId(HttpServletRequest request) {
        UserInfo userInfo = super.getLoginUserInfo(request);
        return ServerResponse.createBySuccess(deviceAnnualFeeService.findExpireListByUserId(userInfo));
    }
}
